//
//  PlayMusicViewButton.swift
//  NetMusic
//
//  Created by gl on 16/2/18.
//  Copyright © 2016年 CoderC. All rights reserved.
//

import UIKit

class PlayMusicViewButton: UIView {

    
    weak var delegate: PlayMusicViewButtonDelegate?
    
    
    
    let gifImageView = UIImageView(frame: CGRectMake(0, 0, 25, 25))
    let animaArray: [UIImage] = [UIImage(named: "cm2_top_icn_playing")!, UIImage(named: "cm2_top_icn_playing2")! , UIImage(named: "cm2_top_icn_playing3")! , UIImage(named: "cm2_top_icn_playing4")! , UIImage(named: "cm2_top_icn_playing5")! ,UIImage(named: "cm2_top_icn_playing6")!,UIImage(named: "cm2_top_icn_playing5")!,UIImage(named: "cm2_top_icn_playing4")!,UIImage(named: "cm2_top_icn_playing3")!,UIImage(named: "cm2_top_icn_playing2")!,UIImage(named: "cm2_top_icn_playing")!]
    let button = UIButton(frame: CGRectMake(0, 0, 25, 25))
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        
        gifImageView.animationImages = animaArray
        gifImageView.animationDuration = 0.6
        gifImageView.animationRepeatCount = 999
        gifImageView.startAnimating()
        addSubview(gifImageView)
        
        
        
        
        button.addTarget(self, action: "buttonClick", forControlEvents: UIControlEvents.TouchUpInside)
        addSubview(button)
        
    }

    func buttonClick() {
        delegate?.PlayMusicViewButtonClick()
        print("哈哈")
    }
    
    override func layoutSubviews() {
//        gifImageView.snp_makeConstraints { (make) -> Void in
//            make.left.equalTo(self)
//            make.right.equalTo(self)
//            make.top.equalTo(self)
//            make.bottom.equalTo(self)
//        }
//        button.snp_makeConstraints { (make) -> Void in
//            make.left.equalTo(self)
//            make.right.equalTo(self)
//            make.top.equalTo(self)
//            make.bottom.equalTo(self)
//        }
    }
    
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}


protocol PlayMusicViewButtonDelegate: class{
    func PlayMusicViewButtonClick()
}





